﻿using System;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;


namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            //IndexRecorder.taskCount = 5;
            //IndexRecorder idx = new IndexRecorder();
            //idx.Start = 10;
            //idx.End = 20;
            //for (int i1 = 0; i1 < IndexRecorder.taskCount; i1++)
            //{
            //    idx.GetSeg(out int start, out int endp1, i1);
            //    Console.WriteLine($"  {start}  {endp1}  ");
            //}
            //Console.WriteLine("==============================");
            //IndexAndSegment ids = new IndexAndSegment();
            //ids.Start = idx.Start;
            //ids.End = idx.End;
            //ids.SplitIndex(IndexRecorder.taskCount);
            //for (int i1 = 0; i1 < IndexRecorder.taskCount; i1++)
            //{
            //    ids.GetSeg(out int start, out int endp1, i1);
            //    Console.WriteLine($"  {start}  {endp1}  ");
            //}
            Console.ReadLine();
        }

    }

    public struct IndexRecorder
    {
        public int Start;
        public int End;
        public static int taskCount;
        public void GetSeg(out int start, out int endPlus1, int segIndex)
        {
            int nodeCount = GetCount();
            start = Start + nodeCount * segIndex / taskCount;
            endPlus1 = Start + nodeCount * (segIndex + 1) / taskCount;
        }
        public int GetCount()
        {
            return End - Start + 1;
        }
    }
    public struct IndexAndSegment
    {
        public int Start;
        public int End;
        private int interval;
        private int yu;
        public void GetSeg(out int start, out int endPlus1, int segIndex)
        {
            start = Start + segIndex * interval;
            if (segIndex < yu)
            {
                start += segIndex;
                endPlus1 = start + interval + 1;
            }
            else
            {
                start += yu;
                endPlus1 = start + interval;
            }
        }
        public void SplitIndex(int segCount)
        {
            int totalNum = End - Start + 1;
            this.interval = totalNum / segCount;
            this.yu = totalNum - interval * segCount;
        }
        public int GetCount()
        {
            return End - Start + 1;
        }
    }
}
